package cn.yeziji.forum.dto.shareLink;

import cn.yeziji.forum.entity.ForumShareLinkEntity;
import cn.yeziji.forum.utils.NanoIdUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 分享链接传入值对象
 *
 * @author gzkemays
 * @since 2022/11/11 3:53 PM
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ShareLinkDTO {
  String linkName;
  String linkUrl;
  String linkSrc;
  String linkTags;
  String linkDesc;
  String nickname;

  public ForumShareLinkEntity buildEntity() {
    ForumShareLinkEntity entity = new ForumShareLinkEntity();
    entity.setLinkUrl(linkUrl);
    entity.setLinkSrc(linkSrc);
    entity.setLinkTags(linkTags);
    entity.setLinkDesc(linkDesc);
    entity.setLinkName(linkName);
    entity.setNickname(nickname);
    return entity;
  }

  public ForumShareLinkEntity createEntity() {
    ForumShareLinkEntity entity = new ForumShareLinkEntity();
    entity.setId(NanoIdUtils.randomNaoId(20));
    entity.setLinkUrl(linkUrl);
    entity.setLinkSrc(linkSrc);
    entity.setLinkTags(linkTags);
    entity.setLinkDesc(linkDesc);
    entity.setLinkName(linkName);
    entity.setNickname(nickname);
    return entity;
  }
}
